package com.binance.zkconfig.app.listener;

import com.binance.zkconfig.app.listener.event.ApplicationReadyEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * Created by Fei.Huang on 2018/8/28.
 */
@Slf4j
public class ApplicationReadyListener implements ApplicationListener<ContextRefreshedEvent>, ApplicationEventPublisherAware {

    private ApplicationEventPublisher publisher;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        publisher.publishEvent(new ApplicationReadyEvent(this));
        log.info("ZkConfig publish applicationReady event");
    }

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
        this.publisher = publisher;
    }

}
